package vn.edu.ptithcm.pim.dao;

import vn.edu.ptithcm.pim.dom.Group;

import java.util.List;

import org.hibernate.LockMode;
import org.hibernate.Transaction;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

@SuppressWarnings("rawtypes")
public class GroupDao extends HibernateDaoSupport {
	public void save(Group group) {
		try {
			Transaction tx = getSession().beginTransaction();
			getHibernateTemplate().save(group);
			tx.commit();
		} catch (RuntimeException re) {
			throw re;
		}
	}

	public void saveOrUpdate(Group group) {
		try {
			Transaction tx = getSession().beginTransaction();
			getHibernateTemplate().saveOrUpdate(group);
			tx.commit();
		} catch (RuntimeException re) {
			throw re;
		}
	}

	public void lock(Group group) {
		try {
			Transaction tx = getSession().beginTransaction();
			getHibernateTemplate().lock(group, LockMode.NONE);
			tx.commit();
		} catch (RuntimeException re) {
			throw re;
		}
	}

	public void delete(Group group) {
		try {
			Transaction tx = getSession().beginTransaction();
			getHibernateTemplate().delete(group);
			tx.commit();
		} catch (RuntimeException re) {
			throw re;
		}
	}

	public Group merge(Group group) {
		try {
			return (Group) getHibernateTemplate().merge(group);
		} catch (RuntimeException re) {
			throw re;
		}
	}

	public Group findById(java.lang.Long id) {
		try {
			return (Group) getHibernateTemplate().get(Group.class, id);
		} catch (RuntimeException re) {
			throw re;
		}
	}

	public List findByExample(Group group) {
		try {
			return getHibernateTemplate().findByExample("Group", group);
		} catch (RuntimeException re) {
			throw re;
		}
	}

	public List getAll() {
		try {
			return getHibernateTemplate().loadAll(Group.class);
		} catch (RuntimeException re) {
			throw re;
		}
	}
}
